home *** CD-ROM | disk | FTP | other *** search
/ Aminet 41 / Aminet 41 (2001)(Schatztruhe)[!][Feb 2001].iso / Aminet / gfx / edit / AmiCAD_2.07.lha / AmiCAD / ARexx / ChercherTexte.AmiCAD < prev    next >
Text File  |  2000-11-04  |  2KB  |  98 lines

  1. /* Recherche d'un texte
  2. Version 1.00: 3 juin 1999
  3. Version 1.01: 13 avril 2000 (modif fonctions OBJECTS, LOCK, UNLOCK)
  4. Version 1.02: 4 novembre 2000 (localisation anglais/français)
  5. $VER: 1.01 (© R.Florac, 13 avril 2000) */
  6.  
  7. options results     /* indispensable pour récupérer le résultat des macros */
  8.  
  9. signal on error     /* pour l'interception des erreurs */
  10. signal on syntax
  11.  
  12. 'LANGUAGE'
  13. if result='français.language' then fr=1
  14. else fr=0
  15.  
  16. texte=""
  17. 'LOCK:FIRSTSEL'; i=result
  18. if i>0 then do
  19.     'IF(TYPE('i')==TEXTE,READTEXT('i'),"")'; texte=result
  20.     if result="" then do
  21.     'IF(TYPE('i')==REFERENCE,READTEXT('i'),"")'; texte=result
  22.     if result="" then do
  23.         'IF(TYPE('i')==VALEUR,READTEXT('i'),"")'; texte=result
  24.     end
  25.     end
  26. end
  27.  
  28. if texte="" then do
  29.     if fr=1 then 'ASKTEXT("Texte à chercher ?","")'
  30.     else 'ASKTEXT("Text to search ?","")'
  31.     texte=result
  32. end
  33. if texte='' then do
  34.     'UNLOCK'
  35.     exit
  36. end
  37.  
  38. call 'Travail:AmiCAD/Arexx/InitObjets.AmiCAD'
  39.  
  40. nf=0
  41. if fr=1 then 'TITLE("Recherche en cours..."):OBJECTS'
  42. else 'TITLE("Searching..."):OBJECTS'
  43. o=result
  44. do i=1 to o
  45.     'IF(TYPE('i')==TEXTE,READTEXT('i'),"")'
  46.     t=result
  47.     if t ~= "" then do
  48.     if t=texte then do
  49.         'MARK('i')'
  50.         nf=nf+1
  51.     end
  52.     end
  53. end
  54.  
  55. i=1
  56. do while i>0
  57.     'FINDREF('i',"'texte'")'; i=result
  58.     if i>0 then do
  59.     'MARK('i'):MARK(GETREF('i'))'
  60.     nf=nf+1
  61.     i=i+1
  62.     if i>o then leave
  63.     end
  64. end
  65.  
  66. i=1
  67. do while i>0
  68.     'FINDVAL('i',"'texte'")'; i=result
  69.     if i>0 then do
  70.     'MARK('i'):MARK(GETVAL('i'))'
  71.     nf=nf+1
  72.     i=i+1
  73.     if i>o then leave
  74.     end
  75. end
  76.  
  77. if fr=1 then do
  78.     if nf > 0 then 'TITLE(""):MESSAGE("Texte «'texte'»"+CHR(10)+"trouvé 'nf' fois"):UNLOCK'
  79.     else 'TITLE(""):MESSAGE("'texte'"+CHR(10)+"non trouvé"):UNLOCK'
  80. end
  81. else do
  82.     if nf > 0 then 'TITLE(""):MESSAGE("'texte'"+CHR(10)+"found 'nf' times"):UNLOCK'
  83.     else 'TITLE(""):MESSAGE("'texte'"+CHR(10)+"not found"):UNLOCK'
  84. end
  85. exit
  86.  
  87. /* Traitement des erreurs, interruption du programme */
  88. syntax:
  89. erreur=RC
  90. if fr=1 then 'MESSAGE("Erreur de syntaxe"+CHR(10)+"en ligne 'SIGL'"+CHR(10)+"'errortext(erreur)'"):UNLOCK'
  91. else 'MESSAGE("Syntax error"+CHR(10)+"in line 'SIGL'"+CHR(10)+"'errortext(erreur)'"):UNLOCK'
  92. exit
  93.  
  94. error:
  95. if fr=1 then 'MESSAGE("Erreur en ligne 'SIGL'"):UNLOCK'
  96. else 'MESSAGE("Error in line 'SIGL'"):UNLOCK'
  97. exit
  98.